package com.xbongbong.saas.enums.mini;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.PaasConstant;
import lombok.Getter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

/**
 * 应用模块名称<p>
 * 代码描述<p>
 * Company: 逍邦网络科技有限公司<p>
 *
 * @author chenshan
 * @version v1.0
 * @since 2020/9/3 1:41 下午
 */
@Getter
@ToString
public enum DingBundleUserOperateEnum {
    
    ADD_MEMBER(1,"新增成员"),
    DELETE_MEMBER(2,"删除成员"),
    UPDATE_MEMBER(3,"修改成员"),
    /**
     * 未知规则,当异常时用于返回
     */
    UNKNOWN(404, ""),
    ;
    
    private Integer code;
    
    private String describe;
    
    DingBundleUserOperateEnum(Integer code, String describe){
        this.code = code;
        this.describe = describe;
    }
    
    public static DingBundleUserOperateEnum getByCode(Integer code) {
        for ( DingBundleUserOperateEnum cacheCode : values()) {
            if (cacheCode.getCode().equals(code)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
    
    public static List<DingBundleUserOperateEnum> getAllEnum() {
        List<DingBundleUserOperateEnum> managePushEnumList = new ArrayList<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for ( DingBundleUserOperateEnum cacheCode : values()) {
            if (cacheCode == UNKNOWN) {
                continue;
            }
            managePushEnumList.add(cacheCode);
        }
        return managePushEnumList;
    }
    
    
    public String getDescribe() {
        return I18nMessageUtil.getMessage(describe);
    }
}
